#include<stdio.h>
void main(){

    char filename[50];
    printf("please input file's name;\n");
    scanf("%s",filename);
    ascii(filename);
    change(filename);

}
void ascii(char *filename)
{FILE *fp;
char ch;
   fp=fopen(filename,"r");
    ch=fgetc(fp);
printf("ascii码输出为：\n");
    while(ch!=EOF)
    {if(ch=='\n') printf("\n");
        else printf("%4d",ch);
        ch=fgetc(fp);
    }
}
void change(char *filename)
{
FILE *fp;
char ch;
    printf("16进制输出为：\n");
    fp=fopen(filename,"r");
        ch=fgetc(fp);
    while(ch!=EOF)
    {
if(ch=='\n') printf("\n");
        else printf("%4x",ch);
        ch=fgetc(fp);
    }
    fclose(fp);
}
